package com.lukk.controller;

import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.lukk.service.IMerchantsWalletRecordService;

/**
 * 
 * MerchantsWalletRecordController 下午5:37:52
 * 
 * Copyright zhaocj Inc. All rights reserved. Love ME Like Justin Bieber.
 */
@Controller
@RequestMapping("/merchantsWalletRecord")
public class MerchantsWalletRecordController {
	private static Logger logger = LogManager.getLogger(MerchantsWalletRecordController.class.getName());
	@Resource
	IMerchantsWalletRecordService merchantsWalletRecordService;

	// 解析视图
	@RequestMapping("/makeupMoneyForIndent")
	public String makeupMoneyForIndent(Model model) {
		model.addAttribute("oneMenu", "merchantIndentManage");
		model.addAttribute("twoMenu", "makeupMoney");
		return "/cms/merchantIndentManage/makeupMoney";
	}

	/**
	 * 添加一个补差价记录
	 * @param cause
	 * @param indentID
	 * @param merchantID
	 * @param workerID
	 * @param moreMoney
	 * @return
	 */
	@RequestMapping("/payMoreMoneyForIndent")
	public @ResponseBody boolean payMoreMoneyForIndent(String cause, Integer indentID, Integer merchantID,
			Integer workerID, Double moreMoney) {
		logger.debug("接受的参数有：{}，{}，{}，{}，{}", cause, indentID, merchantID, workerID, moreMoney);
		merchantsWalletRecordService.insertPayMoreMoneyRecord(cause, indentID, merchantID, workerID, moreMoney);
		return true;
	}

	/**
	 * 跟配分配的商人查询补差价信息
	 * @param offset
	 * @param limit
	 * @param sort
	 * @param order
	 * @param indentID
	 * @param beginTime
	 * @param endTime
	 * @param payStatus
	 * @param session
	 * @return
	 */
	@RequestMapping("/queryMerchantWalletRecordByMechant")
	public @ResponseBody Map<String, Object> queryMerchantWalletRecordByMechant(Integer offset, Integer limit,
			String sort, String order, Integer indentID, String beginTime, String endTime, Integer payStatus,
			HttpSession session) {
		logger.debug("接受的参数有：{}，{}，{}，{}，{}，{}，{},{}", offset, limit, sort, order, indentID, beginTime, endTime,
				payStatus);
		Map<String, Object> retMap = null;
		try {
			retMap = merchantsWalletRecordService.selectMerchantWalletRecordByMechant(offset, limit, sort, order,
					indentID, beginTime, endTime, payStatus, session);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return retMap;
	}
}
